@extends('admin.app')

@section('breadcrumb')
<div class="bg-light lter b-b wrapper-md">
  <ol class="breadcrumb bg-light lter m-n no-padder">
    <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
    <li>Rbac</li>
    <li><a href="{{ admin_action('Rbac\RolesController@index') }}">角色管理</a></li>
    <li class="active">编辑角色</li>
  </ol>
</div>
@endsection

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      角色菜单信息
    </div>
    <div class="panel-body">
      <form class="form-horizontal" action="{{ admin_action('Rbac\RolesController@savePermission',[$role]) }}" method="post">
        {{ csrf_field() }}
        <div class="form-group">
        	<div class="col-sm-8 col-sm-offset-2">
		        <h2>权限</h2>
		        <div id="treeview" class="treeview">
		          	<ul class="list-group">
		          	@forelse($permissions as $item)
			          	<li class="list-group-item {{ $item['level']>0?'hide':'' }}" pid="{{$item['pid']}}" aid="{{$item['id']}}">
			          		@for($i=1;$i<$item['level']+1;$i++)
			          			<span class="indent"></span>
			          		@endfor
			          		<span class="icon glyphicon glyphicon-chevron-right"></span>
			          		<label class="checkbox-inline i-checks"><input type="checkbox" name="item[]" value="{{$item['id']}}" {{in_array($item['id'],$role_permission)?'checked':''}}><i></i>{{$item['name']}}</label>
			          	</li>
		          	@empty
		          		<h2>无菜单</h2>
		          	@endforelse
		          	</ul>
		        </div>
        	</div>
	    </div>
        <div class="form-group">
          <div class="col-lg-4 col-lg-offset-2">
            <a href="{{ admin_action('Rbac\RolesController@index') }}" class="btn btn-default">返&nbsp;回</a>
            <button type="submit" class="btn btn-primary">保&nbsp;存</button>
          </div>
        </div>
      </form>
    </div>
  </div>
@endsection
@section('styles')
<link rel="stylesheet" type="text/css" href="{{asset('resources/admin/plugins/bootstrap-treeview/bootstrap-treeview.css')}}">
@endsection
@section('scripts')
<script src="{{asset('resources/admin/plugins/bootstrap-treeview/bootstrap-treeview.js')}}"></script>
@endsection
